//
// Created by vcq on 21/4/2.
//
#include "model/_finishrequire_goal.hpp"
static void GetFinishRequire_Goal(request& req, response& res) {
    if (!check_login(req, res)) {
        return;
    }
    basic_string_view<char> id = req.get_query_value("id");
    basic_string_view<char> _finishrequire_id = req.get_query_value("_finishrequire_id");
    basic_string_view<char> _goal_id = req.get_query_value("_goal_id");
    basic_string_view<char> _plan_id = req.get_query_value("_plan_id");
    json item = MGetFinishRequire_Goal(id, _goal_id, _finishrequire_id, _plan_id);
    res.set_status_and_content(status_type::ok, item.dump(), req_content_type::json);
}

static void SaveFinishRequire_Goal(request& req, response& res) {
    if(!check_login(req,res)){
        return;
    }
    struct _finishrequire_goal _finishrequire_goal1{};
    _finishrequire_goal1.id = atoi(req.get_query_value("id").data());
    _finishrequire_goal1._finishrequire_id = atoi(req.get_query_value("_finishrequire_id").data());
    _finishrequire_goal1._plan_id = atoi(req.get_query_value("_plan_id").data());
    _finishrequire_goal1.note = req.get_query_value("note");
    _finishrequire_goal1._goal_id=atoi(req.get_query_value("_goal_id").data());
    MAddFinishRequire_Goal(_finishrequire_goal1);
    res.set_status_and_content(status_type::ok);
}


static void DeleteFinishRequire_Goal(request& req, response& res) {
    if(!check_login(req,res)){
        return;
    }
    MDeleteFinishRequire_Goal(req.get_query_value("id"));
    res.set_status_and_content(status_type::ok);
}
